import Taro, { Component } from '@tarojs/taro'
import { Button, Image, View } from '@tarojs/components'
import './index.scss'
import {toCartPage, toHomePage, toUserPage, toServiceComplaint} from "@/utils/page_router"
import homeLogo from "@/assets/icon/goods-foot_home2.png"
import cartLogo from "@/assets/icon/goods-foot_cart.png"
import userLogo from "@/assets/icon/goods-foot_user.png"
import shareLogo from "@/assets/icon/goods-foot_share.png"
import serviceLogo from "@/assets/icon/goods-foot_service2.png"
import {FyImg} from "@/components/index";

interface IProps {
  menus: any
  onShare: any
}

const fun = function (){}
export default class Index extends Component<IProps, {}> {
  props: any

  static options = {
    addGlobalClass: true
  }

  render() {
    const prefixCls = 'goods-foot'
    const { menus=[], onShare }  = this.props
    const defMenus = {
      "home": {
        name: '首页',
        icon: homeLogo,
        onClick: toHomePage
      },
      "share": {
        name: '分享',
        icon: shareLogo,
        onClick: onShare
      },
      "wxShare": {
        name: '分享',
        icon: shareLogo,
        openType: 'share',
        onClick: fun
      },
      "cart": {
        name: '购物车',
        icon: cartLogo,
        onClick: toCartPage
      },
      "user": {
        name: '我的',
        icon: userLogo,
        onClick: toUserPage
      },
      "service": {
        name: '客服',
        icon: serviceLogo,
        onClick: toServiceComplaint
      }
    }
    return (
      <View className={`${prefixCls} thin-border__t`}>
        <View className={`${prefixCls}__left`}>
          {menus.map(menu => {
            return (<Button key={menu} openType={defMenus[menu]['openType']} className={`${prefixCls}__menu`} onClick={defMenus[menu].onClick}>
              <FyImg className={`${prefixCls}__menu-icon`} src={defMenus[menu]['icon']}/>
              <View className={`${prefixCls}__menu-text`}>{defMenus[menu]['name']}</View>
            </Button>)
          })}
        </View>
        <View className={`${prefixCls}__right`}>
          <View className={`${prefixCls}__btns`}>
            {this.props.children}
            {/*{!disabled && <Button className={`${prefixCls}__btns-btn ${prefixCls}__cart-btn xf-btn`} onClick={() => onAddCart()}>加入购物车</Button>}*/}
            {/*<Button disabled={disabled} className={`${prefixCls}__btns-btn xf-btn xf-btn-primary`} onClick={() => onBuyNow()}>{}立即购买</Button>*/}
          </View>
        </View>
      </View>
    )
  }
}
